package main

import (
	"context"
	"log"
	"time"

	pb "gitee.com/mayxiangfan/go-study/rpc/gRPC/proto"
	"google.golang.org/grpc"
)

func main() {
	//创建grpc连接
	conn, err := grpc.Dial("127.0.0.1:8081", grpc.WithInsecure(), grpc.WithBlock())
	if err != nil {
		log.Fatal(err.Error())
	}
	defer conn.Close()
	client := pb.NewUserServiceClient(conn)

	ctx, cancel := context.WithTimeout(context.Background(), time.Second)
	defer cancel()

	request := &pb.UserRequest{Id: 0}
	info, err := client.GetUserInfo(ctx, request)
	if err != nil {
		log.Fatal(err.Error())
	}
	log.Println(info)
}
